home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
T-TPUG Old Monthly Disks
/
(c)t2.d64
/
pegsol.d
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-04
|
7KB
|
222 lines
1 REM - PEG SOLITAIRE FOR COMMODORE 64
2 REM - DANIEL MILLER
3 REM - 2815 34 STREET
4 REM - ASTORIA, QUEENS
5 REM - NEW YORK, NEW YORK 11103
6 REM - 03/06/83
7 REM *********************************
10 DIM A$(3),B(37),C$(15),C(37),D$(15)
20 PRINTCHR$(147):GOTO10000
40 POKEVO,15:POKEWV,17:POKEAT,15:POKEHI,68:POKELO,149
50 FOR TM=1 TO 100:NEXT TM:POKEWV,0
55 POKEVO,15:POKEWV,17:POKEAT,15
60 POKEWV,17:POKEHI,34:POKELO,75
75 FOR TM=1 TO 100:NEXT TM:POKEWV,0:RETURN
150 FOR X=1 TO 37:B(X)=2:NEXT:B(19)=1
160 AA=1:GOSUB230:AA=0
200 PRINTTAB(14)DW$;RV$;"PEG SOLITAIRE";RO$;:FOR TM=1 TO 2500:NEXT TM
215 GOSUB1000
220 REM - PUZZLE SCREEN
230 PRINT CHR$(19);
400 PRINTLEFT$(DO$,4)TAB(15)A$(B(1));U$TAB(20)A$(B(2));U$TAB(25)A$(B(3)):PRINT
405 IF VAL(F2$)<>1 THEN410
406 GOSUB40
410 PRINTTAB(10)A$(B(4));U$TAB(15)A$(B(5));U$TAB(20)A$(B(6));U$TAB(25)A$(B(7));
415 PRINTU$TAB(30)A$(B(8)):PRINT
416 IF VAL(F2$)<>2 THEN420
417 GOSUB40
420 PRINTTAB(5)A$(B(9));U$TAB(10)A$(B(10));U$TAB(15)A$(B(11));
421 PRINTU$TAB(20)A$(B(12));
425 PRINTU$TAB(25)A$(B(13));U$TAB(30)A$(B(14));U$TAB(35)A$(B(15)):PRINT
426 IF VAL(F2$)<>3 THEN430
427 GOSUB40
430 PRINTTAB(5)A$(B(16));U$TAB(10)A$(B(17));U$TAB(15)A$(B(18));
431 PRINTU$TAB(20)A$(B(19));U$TAB(25)A$(B(20));U$TAB(30)A$(B(21));
432 PRINTU$TAB(35)A$(B(22)):PRINT
435 IF VAL(F2$)<>4 THEN440
436 GOSUB40
440 PRINTTAB(5)A$(B(23));U$TAB(10)A$(B(24));U$TAB(15)A$(B(25));
441 PRINTU$TAB(20)A$(B(26));U$TAB(25)A$(B(27));U$TAB(30)A$(B(28));
442 PRINTU$TAB(35)A$(B(29)):PRINT
445 IF VAL(F2$)<>5 THEN450
446 GOSUB40
450 PRINTTAB(10)A$(B(30));U$TAB(15)A$(B(31));U$TAB(20)A$(B(32));
451 PRINTU$TAB(25)A$(B(33));U$TAB(30)A$(B(34)):PRINT
455 IF VAL(F2$)<>6 THEN460
456 GOSUB40
460 PRINTTAB(15)A$(B(35));U$TAB(20)A$(B(36));U$TAB(25)A$(B(37))
465 IF VAL(F2$)<>7 THEN500
466 GOSUB40
500 D=99:E=120:FOR X=1202 TO 1992 STEPE:POKEX,D:NEXT
510 FOR X=1207 TO 1997 STEPE:POKEX,D:NEXT
520 FOR X=1317 TO 1797 STEPE:POKEX,D:NEXT
530 FOR X=1332 TO 1812 STEPE:POKEX,D:NEXT
540 FOR X=1432 TO 1672 STEPE:POKEX,D:NEXT
545 FOR X=1457 TO 1697 STEPE:POKEX,D:NEXT
548 IF AA=1 THEN RETURN
550 FOR X=55342 TO 55372 STEP5:POKEX,10:NEXT
555 X=49:FOR Y=1070 TO 1100 STEP5:POKEY,X:X=X+1:NEXT
560 FOR X=55418 TO 56218 STEPE:POKEX,10:NEXT
565 X=49:FOR Y=1146 TO 1946 STEPE:POKEY,X:X=X+1:NEXT
570 S1$=RV$+CHR$(159)+"MOVE #"+RO$:PRINTLEFT$(DO$,22);TAB(30) S1$;
600 S1$=RV$+CHR$(159)+"FROM"+RO$:S2$=RV$+CHR$(159)+"TO"+RO$
605 PRINT DO$;TAB(10) S1$;TAB(24) S2$;
610 PRINT DOWN$;TAB(15);" ";DOWN$;TAB(15);"";
611 GET F$:IF F$="" THEN611
612 F0=ASC(F$):IF F0=133 OR F0=134 OR F0=135 OR F0=136 THEN740
616 GET G$:IF G$="" THEN616
617 FR$=F$+G$:PRINT FR$;:F$="":G$=""
618 IF LEFT$(FR$,1)<"1" OR LEFT$(FR$,1)>"9" THEN FR$="":GOTO610
619 IF RIGHT$(FR$,1)<"1" OR RIGHT$(FR$,1)>"9" THEN FR$="":GOTO610
620 H=VAL(FR$):F1=H:GOSUB8000:FR=H:C(FR)=VAL(MID$(D$,FR,1))
660 PRINT DOWN$;TAB(27);" ";DOWN$;TAB(27);"";
665 GET F$:IF F$="" THEN665
666 GET G$:IF G$="" THEN666
667 TU$=F$+G$:PRINT TU$;:F$="":G$=""
668 IF LEFT$(TU$,1)<"1" OR LEFT$(TU$,1)>"7" THEN TU$="":GOTO660
669 IF RIGHT$(TU$,1)<"1" OR RIGHT$(TU$,1)>"7" THEN TU$="":GOTO660
670 H=VAL(TU$):T1=H:GOSUB8000:TU=H:C(TU)=VAL(MID$(D$,TU,1))
675 F2$=LEFT$(FR$,1)
680 FR$=MID$(D$,FR,1):TU$=MID$(D$,TU,1)
690 IF FR$="1" THEN ER=1:GOTO900
691 IF TU$="2" THEN ER=2:GOTO900
692 IF FR$="3" OR TU$="3" THEN ER=3:GOTO900
700 C=C(TU):C(TU)=C(FR):C(FR)=C
705 IF F1-T1=2 OR F1-T1=-2 OR F1-T1=20 OR F1-T1=-20 THEN800
710 D$="":FOR X=1 TO 37:D$=D$+RIGHT$(STR$(C(X)),1):NEXT
720 PRINT DOWN$;TAB(15);" ";:PRINT DOWN$;TAB(27);" ";
730 FOR X=1 TO 37:B(X)=VAL(MID$(D$,X,1)):NEXT:GOTO220
740 F0=0:MV=MV+1:PRINT LEFT$(DOWN$,22);TAB(37);STR$(MV);:GOTO220
800 IF ABS(F1-T1)=20 THEN J=1:GOTO820
805 J=2:GOTO830
820 IF F1>T1 THEN825
821 H=F1+10:GOTO826
825 H=F1-10
826 GOSUB8000:C(H)=1:GOTO710
830 IF F1>T1 THEN835
831 H=F1+1:GOTO836
835 H=F1-1
836 GOSUB8000:C(H)=1:GOTO710
900 ON ER GOTO 910,920,930
910 ER$=RV$+"'FROM' POSITION EMPTY"+RO$:GOSUB950:F2$="":GOTO220
920 ER$=RV$+"'TO' POSITION OCCUPIED"+RO$:GOSUB950:F2$="":GOTO220
930 ER$=RV$+"INVALID MOVE"+RO$:GOSUB950:F2$="":GOTO220
950 PRINT DOWN$;TAB(5);" ";
951 FOR X=1 TO 5
952 PRINT DOWN$;TAB(22-(LEN(ER$)/2));ER$;:FOR TM=1 TO 500:NEXT TM
954 PRINT DOWN$;" ";
956 FOR TM=1 TO 500:NEXT TM:NEXT X:RETURN
999 REM - MAIN MENU
1000 S1$=DW$+RV$+CHR$(159)+"PEG SOLITAIRE"+RO$
1010 PRINTCL$:PRINTTAB(14)S1$;DW$
1200 FOR X=1 TO 15:PRINTTAB(5)STR$(X)". ";C$(X):NEXT
1270 RESTORE:FOR X=1 TO 15:READ C$:NEXT
1300 PRINT DW$;TAB(10)"SELECT CHOICE ";:INPUT PZ
1305 IF PZ=15 THEN PRINTCL$:END
1310 ON PZ GOSUB11000,11100,11200,11300,11400,11500,11600,11700,11800,11900
1312 IF PZ<11 THEN1320
1315 ON PZ-10 GOSUB12000,12100,12200,12300
1320 RESTORE:FOR X=1 TO PZ:READ C$:NEXT
1330 RESTORE:FOR X=1 TO 15:READ X$:NEXT
1340 FOR X=1 TO PZ:READ PP$,JJ$,CC$:NEXT
1350 GOSUB7000
1400 D$=D$(PZ):FOR X=1 TO 37:B(X)=VAL(MID$(D$,X,1)):C(X)=B(X):NEXT:F2$=""
1450 POKE53280,8:POKE53281,6:MV=0:PRINTCL$:GOTO230
7000 PRINTCL$:S1$=DW$+RV$+C$+RO$+DW$:PRINTTAB(20-(LEN(C$)/2));S1$
7100 PRINT" IN ORDER TO SOLVE THIS PUZZLE, REMOVE"
7110 S1$=RV$+PP$+RO$:S2$=RV$+JJ$+RO$
7115 PRINT" "S1$;" PIECES IN ";S2$;" MOVES LEAVING THE LAST"
7120 S1$=RV$+CC$+RO$:PRINT" PLAYING PIECE IN POSITION ";S1$;"."
7200 PRINTLEFT$(DOWN$,20);TAB(8)"PRESS <RETURN> TO CONTINUE"
7210 GET RR$:IF RR$="" THEN7210
7220 IF RR$<>CHR$(13) THEN7210
7230 RETURN
8000 IF H=13 THEN H=1:RETURN
8010 IF H=14 THEN H=2:RETURN
8020 IF H=15 THEN H=3:RETURN
8030 IF H=22 THEN H=4:RETURN
8040 IF H=23 THEN H=5:RETURN
8050 IF H=24 THEN H=6:RETURN
8060 IF H=25 THEN H=7:RETURN
8070 IF H=26 THEN H=8:RETURN
8080 IF H=31 THEN H=9:RETURN
8090 IF H=32 THEN H=10:RETURN
8100 IF H=33 THEN H=11:RETURN
8110 IF H=34 THEN H=12:RETURN
8120 IF H=35 THEN H=13:RETURN
8130 IF H=36 THEN H=14:RETURN
8150 IF H=37 THEN H=15:RETURN
8160 IF H=41 THEN H=16:RETURN
8170 IF H=42 THEN H=17:RETURN
8180 IF H=43 THEN H=18:RETURN
8190 IF H=44 THEN H=19:RETURN
8200 IF H=45 THEN H=20:RETURN
8210 IF H=46 THEN H=21:RETURN
8220 IF H=47 THEN H=22:RETURN
8230 IF H=51 THEN H=23:RETURN
8240 IF H=52 THEN H=24:RETURN
8250 IF H=53 THEN H=25:RETURN
8260 IF H=54 THEN H=26:RETURN
8270 IF H=55 THEN H=27:RETURN
8280 IF H=56 THEN H=28:RETURN
8290 IF H=57 THEN H=29:RETURN
8300 IF H=62 THEN H=30:RETURN
8310 IF H=63 THEN H=31:RETURN
8320 IF H=64 THEN H=32:RETURN
8330 IF H=65 THEN H=33:RETURN
8340 IF H=66 THEN H=34:RETURN
8350 IF H=73 THEN H=35:RETURN
8360 IF H=74 THEN H=36:RETURN
8370 IF H=75 THEN H=37:RETURN
8380 IF H=99 THEN8500
8400 FOR X=1 TO 5
8410 S1$=RV$+"INCORRECT FROM/TO POSITION"+RO$
8415 PRINTDO$;TAB(9)S1$;:FOR TM=1 TO 500:NEXT TM
8420 PRINT DOWN$;TAB(9);" ";:FOR TM=1 TO 500:NEXT TM
8430 NEXT X:F2$="":GOTO220
8500 S1$="I HOPE YOU HAD FUN WITH "+RV$+"'PEG SOLITAIRE'"+RO$
8510 PRINT DOWN$;S1$;:FOR TM=1 TO 1500:NEXT TM:PRINTCL$:GOTO1000
9900 DATA LATIN CROSS,GREEK CROSS,FOOTBALL TEAM,PYRAMID OF CHEFREN,SHRINE
9910 DATA PYRAMID OF CHEOPS,TIFFANY LAMP,CENTER TO CENTER,DAVIS JUMP
9920 DATA FIVE CROSSES,PENTAGON,DOUBLE CROSS,TILTED SQUARE,OCTAGRAM
9930 DATA END PROGRAM
9940 DATA 5,5,44,8,6,44,10,8,44,8,8,44,14,12,43,15,12,44,16,10,44,31,18,44
9950 DATA 31,15,35,20,10,44,23,15,44,20,16,44,23,11,44,28,24,44
10000 DW$=CHR$(17):U$=CHR$(145):RV$=CHR$(18):RO$=CHR$(146):BL$=CHR$(144)
10002 WH$=CHR$(5):GR$=CHR$(30):LF$=CHR$(157)+CHR$(157):CL$=CHR$(147)
10005 A$(1)=RV$+BL$+CHR$(117)+CHR$(105)+DW$+LF$+CHR$(106)+CHR$(107)+RO$
10008 A$(2)=RV$+WH$+CHR$(117)+CHR$(105)+DW$+LF$+CHR$(106)+CHR$(107)+RO$
10010 A$(3)=RV$+GR$+CHR$(176)+CHR$(174)+DW$+LF$+CHR$(173)+CHR$(189)+RO$
10020 FOR X=1 TO 15:READ C$(X):NEXT
10030 FOR X=1 TO 24:DO$=DW$+DO$:NEXT X:DO$=CHR$(19)+DO$
10050 VO=54296:WV=54276:AT=54277:HI=54273:LO=54272:F2=0:F2$=""
10100 GOTO150
10999 REM - LATIN CROSS
11000 D$(1)="1111121111222111112111111211111111111":RETURN
11099 REM - GREEK CROSS
11100 D$(2)="1111121111121111222221111211111211111":RETURN
11199 REM - FOOTBALL TEAM
11200 D$(3)="2221222111222111121211111111111111111":RETURN
11299 REM - PYRAMID OF CHEFREN
11300 D$(4)="1113111311121111122211122222131113111":RETURN
11399 REM - THE SHRINE
11400 D$(5)="1211121112222211112111111211112221222":RETURN
11499 REM - PYRAMID OF CHEOPS
11500 D$(6)="1111121111222111222221222222211111111":RETURN
11599 REM - TIFFANY LAMP
11600 D$(7)="1213222312222211112111111211132223222":RETURN
11699 REM - CENTER TO CENTER
11700 D$(8)="2223222322222222221222222222232223222":RETURN
11799 REM - DAVIS JUMP
11800 D$(9)="2223222322221222222222222222232223222":RETURN
11899 REM - FIVE CROSSES
11900 D$(10)="1211222112121212222222121212112221121":RETURN
11999 REM - PENTAGON
12000 D$(11)="1213222312222212222222122222132223111":RETURN
12099 REM - DOUBLE CROSS
12100 D$(12)="1212121211222112222222112221121212121":RETURN
12199 REM - TILTED SQUARE
12200 D$(13)="1211222112222212221222122222112221121":RETURN
12299 REM - OCTAGRAM
12300 D$(14)="1212222212222212222222122222122222121":RETURN